var app = getApp();
Page({
  data: {
    info: {},
    currentSwiper: 0,
    imgheights: [],
    imgwidth: 750,
    current: 0,
    hotelid:0,
    circular:true
  },
  bannerChange(event){
    this.setData({
      currentSwiper: event.detail.current
    })
  },
  imageLoad: function (e) {
    //获取图片真实宽度
    var imgwidth = e.detail.width,
      imgheight = e.detail.height,
      //宽高比
      ratio = imgwidth / imgheight;
    console.log(imgwidth, imgheight)
    //计算的高度值
    var viewHeight = 750 / ratio;
    var imgheight = viewHeight
    var imgheights = this.data.imgheights
    //把每一张图片的高度记录到数组里
    imgheights.push(imgheight)
    this.setData({
      imgheights: imgheights,
    })
  },
  onLoad: function (options) {
    if (options && options.roomid) {
      this.loadDetail(options.roomid)
    }
    if(options.hotelid){
      this.setData({
        hotelid:options.hotelid
      })
    }
  },
  loadDetail(id) {
    var self = this
    app.request({
      url: '/home/room/getInfo',
      method: 'post',
      data: {
        room_id: id
      },
      success: (res) => {
        console.log(res)
        self.setData({
          info: res.result
        })
      }
    })
  }
})